#!/usr/bin/php
<?php

Class Advert_Import
{
var $production;
var $development;

function Advert_Import()
{
## PREPARE CONNECTION ##

$this->production=mysql_connect("localhost","infopark_com_ua","8888zG6Wtv1k",true);
mysql_set_charset ('utf8',$this->production);
mysql_select_db("infopark_com_ua",$this->production);

$this->development=mysql_connect("localhost","infopark_com_ua","8888zG6Wtv1k",true);
mysql_set_charset ('utf8',$this->development);
mysql_select_db("dev_infopark_com_ua",$this->development);

$this->get_data_from_development();
}
function get_data_from_development()
{
$sql="SELECT * FROM node WHERE type IN ('event','media_gallery','page','place','brand','schedule')";
	

$nodes=$this->LIST_Q($sql,$this->development);
#print_r($sql);
foreach($nodes as $node)
  {
    $sql1="UPDATE node SET imported=".$node->nid." WHERE nid=".$node->nid." AND type='".$node->type."'";
    print $sql1."\n";
    $this->QUERY($sql1,$this->production);
  }
}
function Q($str,$string=0)
{
return ($string?"'":"").mysql_escape_string($str).($string?"'":"");
}
function QUERY($sql,$conn)
{
$result=mysql_query($sql,$conn);
return $result;
}
function ROW_Q($sql,$conn)
{
$result=$this->QUERY($sql,$conn);
$r=mysql_fetch_object($result);
if(count($r)==0)$r=false;
return $r;
}
function LIST_Q($sql,$conn)
{

$result=$this->QUERY($sql,$conn);
while($r=mysql_fetch_object($result))
  {
  $data[]=$r;
  }
  
  if(count($data)==0)$data=false;
  return $data;
}

}
function pre($array)
{
print_r($array);
}
$AI=new Advert_Import;

?>